package cn.iocoder.yudao.module.erp.dal.mysql.suppliersendorder;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.erp.controller.admin.suppliersendorder.vo.SupplierSendOrderPageReqVO;
import cn.iocoder.yudao.module.erp.dal.dataobject.suppliersendorder.SupplierSendOrderDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * ERP 随货同行单 Mapper
 * @author ls
 */
@Mapper
public interface SupplierSendOrderMapper extends BaseMapperX<SupplierSendOrderDO> {

    default PageResult<SupplierSendOrderDO> selectPage(SupplierSendOrderPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<SupplierSendOrderDO>()
                .eqIfPresent(SupplierSendOrderDO::getOutOrderId, reqVO.getOutOrderId())
                .eqIfPresent(SupplierSendOrderDO::getIntegrateId, reqVO.getIntegrateId())
                .eqIfPresent(SupplierSendOrderDO::getPurchaseOrderId, reqVO.getPurchaseOrderId())
                .eqIfPresent(SupplierSendOrderDO::getSupplierId, reqVO.getSupplierId())
                .betweenIfPresent(SupplierSendOrderDO::getSendTime, reqVO.getSendTime())
                .eqIfPresent(SupplierSendOrderDO::getTotalPrice, reqVO.getTotalPrice())
                .eqIfPresent(SupplierSendOrderDO::getRemark, reqVO.getRemark())
                .eqIfPresent(SupplierSendOrderDO::getStatus, reqVO.getStatus())
                .eqIfPresent(SupplierSendOrderDO::getProcessInstanceId, reqVO.getProcessInstanceId())
                .betweenIfPresent(SupplierSendOrderDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(SupplierSendOrderDO::getCreateTime));
    }
    default List<SupplierSendOrderDO> getSupplierSendOrderDOListByByOutPurchaseOrderId(String purchaseOrderId) {
        return selectList(SupplierSendOrderDO::getPurchaseOrderId,purchaseOrderId );
    }

    default List<SupplierSendOrderDO> getSupplierSendOrderDOPrintListByOutPurchaseOrderId(String purchaseOrderId) {
        return selectList(SupplierSendOrderDO::getPurchaseOrderId,purchaseOrderId ,SupplierSendOrderDO::getStatus,"0");
    }

    default SupplierSendOrderDO selectByNo(String no){
        return selectOne(SupplierSendOrderDO::getOutOrderId,no);
    }

    List<SupplierSendOrderDO> getSupplierSendOrderItemListByPurchaseOrderIds(@Param("purchaseOrderIds") String[] purchaseOrderIds);
}